﻿using Styx.Common;
using Styx.CommonBot;
using Styx.TreeSharp;
using Action = Styx.TreeSharp.Action;

namespace TuanHA_Monk_Special_Edition_Extreme_PvP
{
    public partial class Classname
    {
        #region WindWalkerRotation

        private Composite WindWalkerRotation()
        {
            return new PrioritySelector(
                new Action(delegate
                               {
                                   //target the lowest threat unit
                                   if (THSettings.Instance.AutoTarget && Me.CurrentTarget != null &&
                                       Me.CurrentTarget.IsValid && Me.CurrentTarget.Distance > 30 && GetUnitNear() &&
                                       UnitNear.IsValid && Me.CurrentTarget != UnitNear)
                                   {
                                       UnitNear.Target();
                                       Logging.Write(LogLevel.Diagnostic, "Switch to Near Target");
                                   }

                                   //target the lowest threat unit
                                   if (THSettings.Instance.AutoTarget && Me.CurrentTarget == null &&
                                       GetUnitNear() &&
                                       UnitNear.IsValid)
                                   {
                                       UnitNear.Target();
                                       Logging.Write(LogLevel.Diagnostic, "Target  Near Unit");
                                   }

                                   //Hold dps on Dungeon 
                                   if ((Me.CurrentMap.IsDungeon ||
                                        Me.CurrentMap.IsRaid) &&
                                       !Me.Combat &&
                                       Me.CurrentTarget != null &&
                                       IsEnemy(Me.CurrentTarget) &&
                                       !Me.CurrentTarget.IsTargetingMyPartyMember &&
                                       !Me.CurrentTarget.IsTargetingMyRaidMember &&
                                       !Me.CurrentTarget.IsTargetingMeOrPet)
                                   {
                                       return RunStatus.Success;
                                   }

                                   return RunStatus.Failure;
                               }),
                //But first, facing target
                new Decorator(
                    ret =>
                    THSettings.Instance.AutoFace &&
                    Attackable(Me.CurrentTarget) &&
                    !Blacklist.Contains(Me.CurrentTarget, BlacklistFlags.All) &&
                    (Me.CurrentTarget.IsTargetingMeOrPet ||
                     Me.CurrentTarget.IsTargetingMyPartyMember ||
                     Me.CurrentTarget.IsTargetingMyRaidMember) &&
                    Me.CurrentTarget.Distance < 15 &&
                    !Me.Mounted &&
                    !IsOverrideModeOn &&
                    !Me.IsFacing(Me.CurrentTarget),
                    new Action(delegate
                                   {
                                       Me.CurrentTarget.Face();
                                       return RunStatus.Failure;
                                   })
                    ),
                //Starting the movement right here
                MovementMoveBehind(ret => Me.CurrentTarget),
                MovementMoveToMelee(ret => Me.CurrentTarget),
                MovementMoveStop(ret => Me.CurrentTarget, 3),
                //DPS Rotation Here
                //WriteTargetInfo(),
                PickHealingSphere(),
                PickChiSphere(),
                SpearHandStrike(),
                SpearHandStrikePlayerLowHP(),
                SetAutoAttack(),
                FortifyingBrew(),
                DampenHarm(),
                EnergizingBrew(),
                TigereyeBrew(),
                ChiBrew(),
                ZenMeditation(),
                TigersLustMe(),
                FlyingSerpentKick(),
                Roll(),
                Provoke(),
                TouchofDeathPvP(),
                TouchofDeath(),
                LegSweepInterrupt(),
                ChargingOxWaveInterrupt(),
                ParalysisInterrupt(),
                CracklingJadeLightningPushBackWW(),
                Transcendence(),
                DiffuseMagic(),
                LegSweepMeLowHP(),
                LegSweepEnemyLowHP(),
                ChargingOxWaveMeLowHP(),
                ChargingOxWaveEnemyLowHP(),
                ParalysisMeLowHP(),
                QuakingPalmMeLowHP(),
                TouchofKarma(),
                FistsofFuryPvP(),
                HealingSphereUrgent(),
                Disable(),
                InvokeXuen(),
                GrappleWeapon(),
                TigerPowerBuff(),
                ExpelHarm(),
                JabCapEnergy(),
                RisingSunKick(),
                ChiWaveMe(),
                ZenSphereMe(),
                RushingJadeWind(),
                SpinningCraneKick(),
                JabNearCapEnergy(), //48000
                FistsofFury(),
                BlackoutKickProc(),
                TigerPowerProc(),
                BlackoutKick(),
                BlackoutKickPvP(),
                Jab(),
                HealingSphereCombat(),
                SpinningFireBlossom(),
                HealingSphereNoCombat(),
                HealingSphereCombatBeforeReachingEnemy(),
                LegacyoftheEmperor(),
                //WriteDebug("LegacyoftheEmperor"),
                LegacyoftheWhiteTiger()
                //PathofBlossoms()
                );
        }

        #endregion
    }
}